pub mod auto;
pub mod esop;
pub mod group;
pub mod pair;
pub mod pbase;
pub mod side;
pub mod stock;

use super::{
    err, err_value, get_dir, json, ok, throw_err, Base, Client, ECode, Lock, MapSv, RNull, Resp,
    VBase, VMap, Value, VecV, SS,
};
use base::tbase::{
    get_cfg, load_box, load_ready, load_ring, log_pack, log_stock, save_cfg, save_data,
    try_rm_task, update_side, update_stock, TBase,
};

pub async fn doit(para: &Value, cmd: &str, key: &str, client: &Client, lock: Lock) -> Resp {
    match cmd {
        "auto" => {
            let v = auto::Auto;
            v.do_cmd(para, key, client, lock).await
        }
        "group" => {
            let v = group::Group;
            v.do_cmd(para, key, client, lock).await
        }
        "pair" => {
            let v = pair::Pair;
            v.do_cmd(para, key, client, lock).await
        }
        "side" => {
            let v = side::Side;
            v.do_cmd(para, key, client, lock).await
        }
        "stock" => {
            let v = stock::Stock;
            v.do_cmd(para, key, client, lock).await
        }
        "wesop" => {
            let v = esop::Esop;
            v.do_cmd(para, cmd, key, client, lock).await
        }
        _ => throw_err!(ECode::NoServe, "no cmd"),
    }
}
